package com.arcadia.d2.hero_attributes.attack;

public class AttackSpeed {

	// base attackSpeed, increased attackSpeed, and increased total attackSpeed
	private double baseAS;
	// iAS is increased AS from abilities and items
	private int iAS;
	// iASTotal is total iAS that consists of iAS from abilities, items and iAgilities
	private int iASTotal;
	
	public AttackSpeed(int iAS){
		this.iAS = iAS;
	}
	
	public AttackSpeed(int heroID, int iAS){
		this.iAS = 0;
		switch (heroID) {
		case 36:
			baseAS = 1.45;// AM
			break;

		case 69:
			baseAS = 1.5; // TB 1.6;
			break;

		case 73:
			baseAS = 1.5; // WR
			break;

		case 8:
			baseAS = 1.6; // HUSKAR
			break;

		case 38:
			baseAS = 1.6; // JUGG
			break;

		case 40:
			baseAS = 1.6; // MOR
			break;

		case 9:
			baseAS = 1.7; // GA 1.4/1.2/1.0;
			break;

		case 50:
			baseAS = 1.7; // LD 1.5;
			break;

		case 31:
			baseAS = 1.7; // LYC 1.5;
			break;

		case 52:
			baseAS = 1.7; // TW 1.55;
			break;

		case 63:
			baseAS = 1.8; // NW
			break;

		case 11:
			baseAS = 1.9; // TP
			break;

		case 30:
			baseAS = 1.9; // SB
			break;

		default:
			baseAS = 1.7; // ELSE
			break;
			}
	}

	// Accessors
	public double getBaseAS() {
		return this.baseAS;
	}

	public int getIAS() {
		return this.iAS;
	}

	public int getIASTotal() {
		return this.iASTotal;
	}

	public double getAttackPerSecond() {
		return (1 + this.iASTotal) / this.baseAS;
	}

	// Mutators		
	public int timesOfAttack(double duration){	//how many times of attacks during the duration 
		return (int)(duration * this.getAttackPerSecond());
	}
	
	public void setIAS(int IAS) {
		this.iAS += iAS;
	}

	public void setIASTotal(int iAgility, int IAS) {
		this.iASTotal += iAgility + IAS;
	}
}
